--  ---------------------------------------------------------------------------
--  @File: errors.ads
--
--  @Project: LiberAda
--  @Version: 1.0
--  @Created: 2009-09-23
--  @Author:  Markus Knau�
--
--  @Description:
--    Provides constants for error messages and routines for printing
--    them on the console.
--
--  @Modifications:
--    +2012-01-13 BM,AZ: Added Help Message system.
--    +2011-04-23 JT: Corrected termination with failure exit code and printing
--      error message to StdErr instead of StdOut.
--    +2009-09-23 MK: Initial release
--  ---------------------------------------------------------------------------

with Ada.Strings.Unbounded;

with Formatter;

package Errors is

   package SU renames Ada.Strings.Unbounded;

   --  ------------------------------------------------------------------------
   --  @Constant: VALUES_FOR_EXTENSIONS_PARAMETER_MISSING
   --  @Description: Error message indicating wrong "-ext" parameter usage.
   VALUES_FOR_EXTENSIONS_PARAMETER_MISSING : constant String :=
     "No values given for extension parameter.";

   --  ------------------------------------------------------------------------
   --  @Constant: INCLUDE_PARAMETER_MISSING
   --  @Description: Error message indicating missing required "-i" parameter.
   INCLUDE_PARAMETER_MISSING : constant String :=
     "Files and directories to include are not specified.";

   --  ------------------------------------------------------------------------
   --  @Constant: VALUES_FOR_INCLUDE_PARAMETER_MISSING
   --  @Description: Error message indicating wrong "-i" parameter usage.
   VALUES_FOR_INCLUDE_PARAMETER_MISSING : constant String :=
     INCLUDE_PARAMETER_MISSING;

   --  ------------------------------------------------------------------------
   --  @Constant: OUTPUT_LOCATION_IS_NO_DIRECTORY
   --  @Description: Error message indicating wrong "-o" parameter usage.
   OUTPUT_LOCATION_IS_NO_DIRECTORY : constant String :=
     "Given location for output is no directory.";

   --  ------------------------------------------------------------------------
   --  @Constant: MULTIPLE_OUTPUT_LOCATIONS
   --  @Description: Error message indicating wrong "-o" parameter usage.
   MULTIPLE_OUTPUT_LOCATIONS : constant String :=
     "Only one location for output is allowed.";

   --  ------------------------------------------------------------------------
   --  @Constant: OUTPUT_LOCATION_VALUE_MISSING
   --  @Description: Error message indicating missing "-o" parameter.
   OUTPUT_LOCATION_VALUE_MISSING : constant String :=
     "Value for -o parameter is missing.";

   --  ------------------------------------------------------------------------
   --  @Constant: OPENING_SOURCE_FILE_FAILED
   --  @Description: Error message indicating source file opening failed.
   OPENING_SOURCE_FILE_FAILED : constant String :=
     "Opening source file failed.";

   --  ----------------------------------------------------------------------
   --  @Constant: NO_SOURCE_FILES
   --  @Description: Error message indicating wrong "-i" parameter usage.
   NO_SOURCE_FILES : constant String :=
     "No source files to read from.";

   --  ----------------------------------------------------------------------
   --  @Constant: HELP_TEXT_PARAMS
   --  @Description: Text for the Print_Help procedure.
   HELP_TEXT_PARAMS : constant Formatter.Values_Array_Type :=
     (SU.To_Unbounded_String(" "),
      SU.To_Unbounded_String("liberada -i <FILES or DIRS> [-r]" &
                             " [-o DIRS] [-ext] [-v]"),
      SU.To_Unbounded_String("$> ./liberada -i hello.adb"),
      SU.To_Unbounded_String("-i"),
      SU.To_Unbounded_String("-r"),
      SU.To_Unbounded_String("-o"),
      SU.To_Unbounded_String("-ext"),
      SU.To_Unbounded_String("-v"));

   --  ------------------------------------------------------------------------
   --  @Procedure: Print_Error
   --  @Description:
   --    Prints the given error message to the console's standard error stream
   --    and sets the exit code to failure, so LiberAda's caller may detect the
   --    unsuccessful LiberAda termination. Please note: this procedure does
   --    not initiate the software exit at all, you have to take care of this
   --    yourself!
   --  @Parameter:
   --    +Msg: error message to print
   procedure Print_Error (Msg : in String);

   --  ------------------------------------------------------------------------
   --  @Procedure: Print_Help
   --  @Description:
   --    Prints a help message with examples and information about
   --    available commandline parameters.
   procedure Print_Help;

end Errors;
